Skip to content

Rust: Make path resolution robust against invalid code with conflicting declarations#21311

Open
hvitved wants to merge 1 commit intogithub:mainfrom
hvitved:rust/path-resolution-remove-duplicates
Open

Rust: Make path resolution robust against invalid code with conflicting declarations#21311
hvitved wants to merge 1 commit intogithub:mainfrom
hvitved:rust/path-resolution-remove-duplicates

Conversation

@hvitved
Copy link
Contributor

@hvitved hvitved commented Feb 11, 2026

Fixes performance on edl-lang/edl, which contains e.g. https://github.com/edl-lang/edl/blob/main/tests/ui/impl-trait/impl-trait-plus-priority.rs.

DCA looks good; a modest performance improvement and slight decrease in inconstencies.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Feb 11, 2026
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Feb 12, 2026
@hvitved hvitved marked this pull request as ready for review February 12, 2026 08:31
@hvitved hvitved requested a review from a team as a code owner February 12, 2026 08:31
@hvitved hvitved requested review from Copilot and paldepind February 12, 2026 08:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves Rust path resolution to remain performant and deterministic in the presence of invalid Rust code that introduces conflicting declarations (e.g., duplicate names), and adds a regression test covering that scenario.

Changes:

  • Add an invalid-Rust test case with conflicting struct A declarations and disable cargo check for that fixture.
  • Update path resolution to avoid combinatorial blow-ups in invalid code by selecting a single (last) matching child item.
  • Update expected test output to reflect the new resolution behavior for the invalid fixture.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
rust/ql/lib/codeql/rust/internal/PathResolution.qll Adjusts child-successor selection to be robust in invalid/conflicting-declaration scenarios.
rust/ql/test/library-tests/path-resolution/invalid/main.rs Adds an invalid Rust fixture with conflicting declarations.
rust/ql/test/library-tests/path-resolution/invalid/options.yml Disables cargo checking for the invalid fixture.
rust/ql/test/library-tests/path-resolution/path-resolution.expected Updates expected results for the new invalid-code path resolution behavior.
Comments suppressed due to low confidence (1)

rust/ql/test/library-tests/path-resolution/invalid/main.rs:6

  • Typo in comment: “precendence” should be “precedence”.
fn f(x: A) {} // $ item=A2 (the later occurence takes precendence)

@hvitved hvitved force-pushed the rust/path-resolution-remove-duplicates branch from 3be76ed to 2de5d24 Compare February 17, 2026 10:09
@hvitved hvitved force-pushed the rust/path-resolution-remove-duplicates branch from 2de5d24 to d3541b8 Compare February 17, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant